﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using ajayumi.develop.win32.Transport.Server.WinForm.Properties;

namespace ajayumi.develop.win32.Transport.Server.WinForm
{
    /// <summary>
    /// 设置窗体
    /// Author  : 黄乙冬
    /// Date    : 2011-08-29
    /// </summary>
    public partial class FrmSetting : Form
    {
        public FrmSetting()
        {
            InitializeComponent();
        }

        private void btnSelSaveDir_Click(object sender, EventArgs e)
        {
            using (FolderBrowserDialog dlg = new FolderBrowserDialog())
            {
                if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    this.txtSaveDir.Text = dlg.SelectedPath;
                }
            }
        }

        private void btnSave_Click(object sender, EventArgs e)
        {
            string saveDir = this.txtSaveDir.Text.Trim();
            if (!Directory.Exists(saveDir))
            {
                MessageBox.Show("上传目录不存在！");
                return;
            }

            AppConfig.SaveDir = saveDir;
            AppConfig.BufferSize = (int)nudBufferSize.Value;
            AppConfig.Save();
            this.Close();
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void FrmSetting_Load(object sender, EventArgs e)
        {
            this.txtSaveDir.Text = AppConfig.SaveDir;
            this.nudBufferSize.Value = AppConfig.BufferSize;
        }
    }
}
